home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CTOOLS10.ARJ / GETOPT.H < prev    next >
C/C++ Source or Header  |  1991-12-31  |  3KB  |  102 lines

  1. /****************************************************************************
  2. *
  3. *                    Copyright (C) 1991 Kendall Bennett.
  4. *                            All rights reserved.
  5. *
  6. * Filename:        $RCSfile: getopt.h $
  7. * Version:        $Revision: 1.6 $
  8. *
  9. * Language:        ANSI C
  10. * Environment:    any
  11. *
  12. * Description:    Header file for command line parsing module. This module
  13. *                contains code to parse the command line, extracting options
  14. *                and parameters in standard System V style.
  15. *
  16. * $Id: getopt.h 1.6 91/12/31 19:41:06 kjb Exp $
  17. *
  18. * Revision History:
  19. * -----------------
  20. *
  21. * $Log:    getopt.h $
  22. * Revision 1.6  91/12/31  19:41:06  kjb
  23. * Modified include files directories.
  24. * Revision 1.4  91/09/27  03:10:56  kjb
  25. * Added compatibility with C++.
  26. * Revision 1.3  91/09/24  19:49:51  kjb
  27. * New version to work with getargs() and print_desc().
  28. * Revision 1.2  91/09/03  18:24:25  ROOT_DOS
  29. * Added the inclusion of the debugging header file.
  30. * Revision 1.1  91/08/16  10:45:11  ROOT_DOS
  31. * Initial revision
  32. ****************************************************************************/
  33.  
  34. #ifndef    __GETOPT_H
  35. #define    __GETOPT_H
  36.  
  37. #ifndef __DEBUG_H
  38. #include "debug.h"
  39. #endif
  40.  
  41. /*---------------------------- Typedef's etc -----------------------------*/
  42.  
  43. #define    ALLDONE        -1
  44. #define    PARAMETER    -2
  45. #define    INVALID        -3
  46. #define    HELP        -4
  47.  
  48. #define    MAXARG        80
  49.  
  50. /* Option type sepecifiers */
  51.  
  52. #define    OPT_INTEGER        'd'
  53. #define    OPT_HEX            'h'
  54. #define    OPT_OCTAL        'o'
  55. #define    OPT_UNSIGNED    'u'
  56. #define    OPT_LINTEGER    'D'
  57. #define    OPT_LHEX        'H'
  58. #define    OPT_LOCTAL        'O'
  59. #define    OPT_LUNSIGNED    'U'
  60. #define    OPT_FLOAT        'f'
  61. #define    OPT_DOUBLE        'F'
  62. #define    OPT_LDOUBLE        'L'
  63. #define    OPT_STRING        's'
  64. #define    OPT_SWITCH        '!'
  65.  
  66. typedef struct {
  67.     uchar    opt;                /* The letter to describe the option    */
  68.     uchar    type;                /* Type descriptor for the option        */
  69.     void    *arg;                /* Place to store the argument            */
  70.     char    *desc;                /* Description for this option            */
  71.     } Option;
  72.  
  73. #define    NUM_OPT(a)    sizeof(a) / sizeof(Option)
  74.  
  75. /*--------------------------- Global variables ---------------------------*/
  76.  
  77. extern    int        nextargv;
  78. extern    char    *nextchar;
  79.  
  80. /*------------------------- Function Prototypes --------------------------*/
  81.  
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85.  
  86. int getopt(int argc,char **argv,char *format,char **argument);
  87. int getargs(int argc,char *argv[],int num_opt,Option optarr[],
  88.             int (*do_param)(char *param,int num));
  89. void print_desc(int num_opt,Option optarr[]);
  90.  
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94.  
  95. #endif
  96.